import SimpleITK as sitk
import numpy as np
import sys, os
from skimage import measure, morphology
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d.art3d import Poly3DCollection

class CTData:
    def __init__(self, mhd_path):
        img = sitk.ReadImage(mhd_path)        
        self.__data = sitk.GetArrayFromImage(img)        
        self.__shape = np.array(self.__data.shape())
        self.__origin = np.array(self._data.GetOrigin())
        self.__space = np.array(self._data.GetSpace())

    @property
    def origin(self):
    	return self.__origin

    @property
    def space(self):
    	return __space

    @property
    def shape(self):
    	return self.__shape

    @property
    def data(self):
    	return self.__data
    	
    def getIndexFromCoord(self, x, y, z):
    	center = np.array((x, y, z))
    	return np.rint((center - self.__origin) / self.__space)


